package com.biyao.controller.state;


import com.biyao.schedulingcommon.response.BaseMsg;
import com.biyao.schedulingcommon.response.FailureMsg;
import com.biyao.schedulingcommon.response.SuccessMsg;
import com.biyao.schedulingentity.state.*;
import com.biyao.service.model.state.RollerExtMessage;
import com.biyao.service.model.state.imp.TRollerExtService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 
 *
 * @author code generator
 * @date 2019-09-16 09:44:10
 */
@Api(tags = {"轧辊当前信息"})
@RestController
@RequestMapping("api/v1/trollerext")
public class TRollerExtController {

    @Autowired
    private RollerExtMessage tRollerExtService;

    @ApiOperation(value = "保存")
    @PostMapping
    public BaseMsg save(@RequestBody TRollerExtEntity tRollerExt) {
        Map map=tRollerExtService.updateDynamics(tRollerExt);
        return new SuccessMsg(map);
    }

    @ApiOperation(value = "查询当前状态")
    @GetMapping
    public BaseMsg selectNowState() {

      return new SuccessMsg(tRollerExtService.selectNowState()) ;

    }

    @ApiOperation(value = "磨辊移动操作")
    @PostMapping("/move")
    public BaseMsg selectMoveState(@RequestBody RollerMoveEntityList rollerMoveEntityList) {
        return new SuccessMsg(tRollerExtService.moveRollerState(rollerMoveEntityList)) ;
    }

    @ApiOperation(value = "查询已磨未上油和已磨已上油的辊")
    @GetMapping("/selectRollerWorkState34")
    public BaseMsg selectRollerWorkState34(){
        return new SuccessMsg(tRollerExtService.selectNowWorkState3());
    }

    @ApiOperation(value = "更新轧辊状态")
    @PostMapping("/updateRollerWorkState")
    public BaseMsg updateRollerWorkState(@RequestBody TRollerExtEntyList list){
        tRollerExtService.updateWorkState(list);
        return new SuccessMsg();
    }
    @ApiOperation(value = "删除当前轧辊")
    @DeleteMapping("delete/{id}")
    public BaseMsg deleteRollerExt(@PathVariable("id") Integer id){
        tRollerExtService.deleteRollerExit(id);
        return new SuccessMsg();
    }

    @ApiOperation(value = "查询轧辊当前状态")
    @GetMapping("nowState/{id}")
    public BaseMsg selectNowStateByCode(@PathVariable("id") Integer id) {
        Map map= tRollerExtService.selectNowStateByCode(id);
        if(map==null){
            return new SuccessMsg(400);
        }
        return new SuccessMsg(map) ;
    }

    @ApiOperation(value = "纯粹轧辊物理地点的变化")
    @PostMapping("/updateRackIdOrGrinderId")
    public BaseMsg updateRackIdOrGrinderId(@RequestBody RollerMoveEntityList rollerMoveEntityList) {
        return new SuccessMsg(tRollerExtService.updateRackIdOrGrinderId(rollerMoveEntityList));
    }

    @ApiOperation(value = "基础信息添加或者更新轧辊的状态")
    @PostMapping("/insertOrUpdateRollerExt")
    public BaseMsg insertOrUpdateRollerExt(@RequestBody TRollerExtBaseEntity tRollerExtEntity){
        tRollerExtService.insertOrUpdateRollerExt(tRollerExtEntity);
        return new SuccessMsg();
    }
    @ApiOperation(value = "基础信息轴承箱更新轧辊的状态")
    @PostMapping("/updateRollerExtByBox")
    public BaseMsg updateRollerExtByBox(@RequestBody TRollerExtEntity tRollerExtEntity){
        tRollerExtService.updateRollerExetByRollerIdBox(tRollerExtEntity);
        return new SuccessMsg();
    }
























}
